package com.zhaojindong.ioc.component.register.fourth;

import lombok.extern.log4j.Log4j;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

@Log4j
public class fourthTest {

    @Test
    public void testMethod() {
        ApplicationContext context = new AnnotationConfigApplicationContext(FourthConfig.class);

        // 默认获取到的是工厂bean调用getObject()创建的对象
        Object bean1 = context.getBean("colorFactoryBean");
        // id 前面加上& 就可以获取工厂bean 本身
        Object bean2 = context.getBean("&colorFactoryBean");
        log.info("bean: " + bean1.getClass());
        log.info("bean: " + bean2.getClass());
    }
}
